<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>

<body>
    <input type="text">
    <input type="button" value="平方" onclick="f()">
    <input type="button" value="求和" onclick="f1()">
    <div>结果:</div>
    <script>
        let t = document.querySelector("input");
        let d = document.querySelector("div");
        function f() {
            if (isNaN(t.value)) {
                d.innerHTML = "王冉婷大傻蛋";
                return;
            }
            d.innerHTML = "结果:" + t.value * t.value;
        }
        function f1() {
            d.innerHTML = "结果:" + (parseFloat(t.value) + parseFloat(t.value));
        }
    </script>
</body>

</html>